import axios from 'axios'
export function requestPath(config,baseURL) {
    const instance = axios.create({
        baseURL: baseURL,
        timeout: 1800000,
        headers: {
            'X-Litemall-Token': localStorage.getItem("X-Litemall-Token")
        }
    })
    instance.interceptors.request.use(config => {
        return config
    }, error => {
        console.log(error)
    })
    return instance(config)
}

export function pathPlanning(routeData,baseURL) {
    return requestPath({
        method: 'post',
        url: '/findpath',
        headers: { "Content-Type": "application/json" },
        data: routeData
    },baseURL)
}

export function saveRoute(routeData,baseURL) {
    return requestPath({
        method: 'post',
        url: '/saveflypath',
        headers: { "Content-Type": "application/json" },
        data: routeData
    },baseURL)
}
export function getRoutePath(baseURL) {
    return requestPath({
        method: 'get',
        url: '/flypaths',
        headers: { "Content-Type": "application/json" },
    },baseURL)
}

export function deleteRoute(id,baseURL) {
   return requestPath({
        method: 'get',
        url: "/delflypath/" + id,
        headers: { "Content-Type": "application/json" },

    },baseURL)
}


